package com.gaming.glb;

import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.input.touch.TouchEvent;
import org.anddev.andengine.opengl.texture.region.BaseTextureRegion;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

public class CatStartGame extends Cat {

	public CatStartGame(Scene mScene, BaseTextureRegion pBallTextureRegion, float posX, float posY, PhysicBall ball) 
	{
		super(mScene, pBallTextureRegion, ball);		
		super.newEntity = new AnimatedSprite(posX, posY + (super.height / 3), (TiledTextureRegion) super.baseTextureRegion)
    	{
			@Override
		    public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) 
			{	
				if (!CatStartGame.this.mBall.isMoving()) {
					((AnimatedSprite)CatStartGame.this.getSprite()).animate(new long[]{200, 200, 200}, 1, 3, false);

					CatStartGame.this.mBall.attachToScene(CatStartGame.this.getPositionX() + CatStartGame.this.width, CatStartGame.this.getPositionY() + .95F * CatStartGame.this.height, CatStartGame.this.mScene);
	    			        			
					CatStartGame.this.mBall.setVelocity(5, 0);
					
					((AnimatedSprite)CatStartGame.this.getSprite()).animate(new long[]{200, 200}, 3, 4, false);	
				}
								
	            return true;
		    }
		};
	}
	
	@Override
	public void attachToScene(Scene scene) {		
    	scene.attachChild(this.newEntity);
    	scene.registerTouchArea(newEntity);
	}	
	
}
